/*
 * ObjectElement.cpp
 *
 *  Created on: 2010-6-7
 *      Author: Guobc
 */

#include "ObjectElement.h"
using namespace HA;

string ObjectElement::mIds[] = { "OBJECT", "" };
string ObjectElement::mEnds[] = { "OBJECT", "BODY", "HTML" , ""};

ObjectElement::ObjectElement() :
	HA::CommonElement() {
}

ASTNodeList ObjectElement::getParameters() {
	ASTNodeList params;
	ASTNode* node;
	ParamElement* param;
	ASTNodeList children = getChildren();
	int size = children.size();
	for (int i = 0; i < size; i++) {
		node = children.item(i);
		param = dynamic_cast<ParamElement*> (node);
		if (param != NULL) {
			params.append(param);
		}
	}
	return params;
}

ParamElement* ObjectElement::getParameter(const string& name) {
	ASTNodeList params;
	ASTNode* node;
	ParamElement* param;
	ASTNodeList children = getChildren();
	int size = children.size();
	for (int i = 0; i < size; i++) {
		node = children.item(i);
		param = dynamic_cast<ParamElement*> (node);
		if (param != NULL) {
			if (param->getParamName() == name) {
				return param;
			}
		}
	}
	return NULL;
}
